-- @Author: 作者QQ381990860
-- @Date:   2021-11-05 10:34:34
-- @Last Modified by:   作者QQ381990860
-- @Last Modified time: 2022-07-23 06:59:07

local 帮派信息类 = class(窗口逻辑)
local tp,zts,zts1
local insert = table.insert

local bpk1 = {"金  库  数","书  院  数","兽  室  数","厢  房  数","药  房  数","仓  库  数","目前容纳金","最大容纳金","最佳研究力","训  练  度","守护兽等级","最佳训练力","目前成员数","最大成员数","药品增加量","目前资材量","最大资材量"}
local bpk2 = {"学 费指 数","物 价指 数","修理费指数"}
local bpk3 = {"需耗损资金","需要建筑进度","需损耗繁荣度","需损耗人气度"}


function 帮派信息类:初始化(根)
	self.ID = 144
	self.x = 200+(全局游戏宽度-800)/2
	self.y = 60
	self.xx = 0
	self.yy = 0
	self.注释 = "帮派信息类"
	self.可视 = false
	self.鼠标 = false
	self.焦点 = false
	self.可移动 = true
	local 资源 = 根.资源
	local 按钮 = 根._按钮
	local 自适应 = 根._自适应
	self.资源组 = {
	[1] = 自适应.创建(0,1,405,417,3,9),--背景
	--[1] = 资源:载入('JM.dll',"网易WDF动画",0x3125AB48),
	[2] = 按钮.创建(自适应.创建(18,4,16,16,4,3),0,0,4,true,true),
	[3] = 按钮.创建(自适应.创建(11,4,55,20,1,3),0,0,4,true,true,"金库"),
	[4] = 按钮.创建(自适应.创建(11,4,55,20,1,3),0,0,4,true,true,"厢房"),
	[5] = 按钮.创建(自适应.创建(11,4,55,20,1,3),0,0,4,true,true,"药房"),
	[6] = 按钮.创建(自适应.创建(11,4,55,20,1,3),0,0,4,true,true,"书院"),
	[7] = 按钮.创建(自适应.创建(11,4,55,20,1,3),0,0,4,true,true,"仓库"),
	[8] = 按钮.创建(自适应.创建(11,4,55,20,1,3),0,0,4,true,true,"兽室"),
	[9] = 按钮.创建(自适应.创建(11,4,75,20,1,3),0,0,4,true,true,"设置内政"),

	[11] = 自适应.创建(4,1,160,180,3,9),
	[12] = 自适应.创建(3,1,100,18,1,3),


	}

	for n=2,9 do
		self.资源组[n]:绑定窗口_(144)
	end

	self.窗口时间 = 0
	tp = 根
	zts = tp.字体表.普通字体
	zts1 = tp.字体表.描边字体

end

function 帮派信息类:打开(数据)
	if  self.可视 then
		self.可视 = false
	 self.所需进度=0
	 self.损耗资金=0
	 self.损耗人气=0
	 self.损耗繁荣=0
	 self.选中类型=""
	else
	if  self.x > 全局游戏宽度 then
		self.x = 0+(全局游戏宽度-800)/2
    end
	insert(tp.窗口_,self)

	self.可视 = true
		 self.数据=数据
		 	 self.所需进度=0
	 self.损耗资金=0
	 self.损耗人气=0
	 self.损耗繁荣=0
	 self.选中类型=""
		tp.运行时间 = tp.运行时间 + 3
		self.窗口时间 = tp.运行时间
		self.可视 = true
	end
end



function 帮派信息类:设置消耗(类型)
	self.选中类型 = 类型
	if 类型 == "金库" then
		self.所需进度 = 500
		self.损耗资金 = 5000000
		self.损耗繁荣 = 300
		self.损耗人气 = 200
	elseif 类型 == "书院" then
		self.所需进度 = 500
		self.损耗资金 = 5000000
		self.损耗繁荣 = 300
		self.损耗人气 = 200
	elseif 类型 == "聚义厅" then
		self.所需进度 = self.数据.规模 * 500 + 500
		self.损耗资金 = self.数据.规模 * 5000000 + 5000000
		self.损耗繁荣 = 500
		self.损耗人气 = 500
	else
		self.所需进度 = 200
		self.损耗资金 = 3000000
		self.损耗繁荣 = 100
		self.损耗人气 = 100
	end
end


function 帮派信息类:显示(dt,x, y)
	self.资源组[2]:更新(x,y)
	self.资源组[3]:更新(x,y)
	self.资源组[4]:更新(x,y)
	self.资源组[6]:更新(x,y)
	self.资源组[7]:更新(x,y)
	self.资源组[5]:更新(x,y)
	self.资源组[8]:更新(x,y)
	self.资源组[9]:更新(x,y)
   self.焦点=false
	if self.资源组[2]:事件判断() then
		self:打开()
	elseif self.资源组[3]:事件判断() then
		self:设置消耗("金库")
	elseif self.资源组[4]:事件判断() then
		self:设置消耗("厢房")
	elseif self.资源组[6]:事件判断() then
		self:设置消耗("书院")
	elseif self.资源组[7]:事件判断() then
		self:设置消耗("仓库")
	elseif self.资源组[5]:事件判断() then
		self:设置消耗("聚义厅")
	elseif self.资源组[8]:事件判断() then
		self:设置消耗("兽室")
	elseif self.资源组[9]:事件判断() then
		if self.选中类型 == "" then
			tp.提示:写入("#y/请先选择要升级的建筑物")
		else
			客户端:发送数据(12, 72, 13, self.选中类型)
		end
	end

	self.资源组[1]:显示(self.x,self.y)
	self.资源组[2]:显示(self.x+self.资源组[1].宽度-20,self.y+3)
	tp.窗口标题背景_:显示(self.x+self.资源组[1].宽度/2-73,self.y)
	zts1:显示(self.x+self.资源组[1].宽度/2-30,self.y+1,"帮派信息")



		for i=0,16 do
			self.资源组[12]:置宽高(100,18)
			self.资源组[12]:显示(self.x+100,self.y+32+i*22)
			zts:显示(self.x+15,self.y+34+i*22,bpk1[i+1])
		end
		for i=0,2 do
			self.资源组[12]:置宽高(80,18)
			self.资源组[12]:显示(self.x+310,self.y+32+i*22)
			zts:显示(self.x+215,self.y+34+i*22,bpk2[i+1])
		end
		for i=0,3 do
			self.资源组[12]:置宽高(90,18)
			self.资源组[12]:显示(self.x+305,self.y+319+i*22)
			zts:显示(self.x+210,self.y+321+i*22,bpk3[i+1])
		end

	self.资源组[11]:显示(self.x+215,self.y+110)
	zts:置颜色(0xFFFFFFFF)
	zts:显示(self.x+235, self.y+114, "选择要升级的建筑")
	self.资源组[3]:显示(self.x+227, self.y+145,true)
	self.资源组[4]:显示(self.x+307, self.y+145,true)
	self.资源组[6]:显示(self.x+227, self.y+180,true)
	self.资源组[7]:显示(self.x+307, self.y+180,true)
	self.资源组[5]:显示(self.x+227, self.y+215,true)
	self.资源组[8]:显示(self.x+307, self.y+215,true)

	self.资源组[9]:显示(self.x+255, self.y+265,true)
	zts:置颜色(0xFF000000)
	zts:显示(self.x+140, self.y+35, self.数据.金库)
	zts:显示(self.x+140, self.y+57, self.数据.书院)
	zts:显示(self.x+140, self.y+79, self.数据.兽室)
	zts:显示(self.x+140, self.y+101, self.数据.厢房)
	zts:显示(self.x+140, self.y+123, self.数据.药房)
	zts:显示(self.x+140, self.y+145, self.数据.仓库)
	zts:显示(self.x+110, self.y+167, self.数据.资金)
	zts:显示(self.x+110, self.y+189, self.数据.金库 * 5000000 + 3000000)
	zts:显示(self.x+140,self.y+ 211, self.数据.书院 * 2)
	zts:显示(self.x+140, self.y+233, 0)
	zts:显示(self.x+140, self.y+255, self.数据.守护兽等级)
	zts:显示(self.x+140, self.y+277, self.数据.兽室 * 5)
	zts:显示(self.x+140, self.y+299, self.数据.当前人数)
	zts:显示(self.x+140, self.y+321, self.数据.人数上限)
	zts:显示(self.x+110, self.y+343, 0)
	zts:显示(self.x+110, self.y+365, self.数据.资材)
	zts:显示(self.x+110, self.y+387, self.数据.仓库 * 100 + 100)
	zts:显示(self.x+337, self.y+35, self.数据.学费指数)
	zts:显示(self.x+337, self.y+57, self.数据.物价指数)
	zts:显示(self.x+337, self.y+79, self.数据.修理指数)
	zts:显示(self.x+313, self.y+321, self.损耗资金)
	zts:显示(self.x+313, self.y+343, self.所需进度)
	zts:显示(self.x+313, self.y+365, self.损耗繁荣)
	zts:显示(self.x+313, self.y+387, self.损耗人气)
	zts:置颜色(0xFFFFFFFF)
end

return 帮派信息类